<?php

namespace app\common\model;

use think\Model;

class Travel extends Model
{
    protected $autoWriteTimestamp = 'int';
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';

    protected function getImagesAttr($value)
    {
        return $value ? explode(',', $value) : [];
    }

    protected function setImagesAttr($value)
    {
        return is_array($value) ? implode(',', $value) : $value;
    }
    
    // 关联分类
    public function category()
    {
        return $this->belongsTo('TravelCategory', 'category_id');
    }
}